package com.example.qxapp.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.example.qxapp.Bean.User;
import com.example.qxapp.MainActivity;
import com.example.qxapp.R;

import java.util.Timer;
import java.util.TimerTask;

import cn.bmob.v3.Bmob;
import cn.bmob.v3.BmobUser;

public class loginActivity extends AppCompatActivity {
    private TextView zc,dl;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        Bmob.initialize(this,"9451c76164239204358c92dfe392808d");
        //延时操作 2s
        Timer timer=new Timer();
        timer.schedule(timetask,2000);
        init();
        dl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(loginActivity.this, dlActivity.class));
            }
        });
        zc.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(loginActivity.this, zcActivity.class));
            }
        });
    }
    TimerTask timetask=new TimerTask() {
        @Override
        public void run() {
            BmobUser bmobUser=BmobUser.getCurrentUser(User.class);
            if (bmobUser!=null){
                //如果已登录
                startActivity(new Intent(loginActivity.this, MainActivity.class));
            }else {
                //未登录
                startActivity(new Intent(loginActivity.this, dlActivity.class));
            }

        }
    };
    private void init(){
        zc=findViewById(R.id.zc);
        dl=findViewById(R.id.dl);
    }
}
